home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / octa209s.zip / octave-2.09 / libs / readline / history.h < prev    next >
C/C++ Source or Header  |  1995-09-22  |  7KB  |  190 lines

  1. /* History.h -- the names of functions that you can call in history. */
  2.  
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6.  
  7. /* The structure used to store a history entry. */
  8. typedef struct _hist_entry {
  9.   char *line;
  10.   char *data;
  11. } HIST_ENTRY;
  12.  
  13. /* A structure used to pass the current state of the history stuff around. */
  14. typedef struct _hist_state {
  15.   HIST_ENTRY **entries;        /* Pointer to the entries themselves. */
  16.   int offset;            /* The location pointer within this array. */
  17.   int length;            /* Number of elements within this array. */
  18.   int size;            /* Number of slots allocated to this array. */
  19.   int flags;
  20. } HISTORY_STATE;
  21.  
  22. /* Flag values for the `flags' member of HISTORY_STATE. */
  23. #define HS_STIFLED    0x01
  24.  
  25. /* Initialization and state management. */
  26.  
  27. /* Begin a session in which the history functions might be used.  This
  28.    just initializes the interactive variables. */
  29. extern void using_history ();
  30.  
  31. /* Return the current HISTORY_STATE of the history. */
  32. extern HISTORY_STATE *history_get_history_state ();
  33.  
  34. /* Set the state of the current history array to STATE. */
  35. extern void history_set_history_state ();
  36.  
  37. /* Manage the history list. */
  38.  
  39. /* Place STRING at the end of the history list.
  40.    The associated data field (if any) is set to NULL. */
  41. extern void add_history ();
  42.  
  43. /* A reasonably useless function, only here for completeness.  WHICH
  44.    is the magic number that tells us which element to delete.  The
  45.    elements are numbered from 0. */
  46. extern HIST_ENTRY *remove_history ();
  47.  
  48. /* Make the history entry at WHICH have LINE and DATA.  This returns
  49.    the old entry so you can dispose of the data.  In the case of an
  50.    invalid WHICH, a NULL pointer is returned. */
  51. extern HIST_ENTRY *replace_history_entry ();
  52.  
  53. /* Stifle the history list, remembering only MAX number of entries. */
  54. extern void stifle_history ();
  55.  
  56. /* Stop stifling the history.  This returns the previous amount the
  57.    history was stifled by.  The value is positive if the history was
  58.    stifled, negative if it wasn't. */
  59. extern int unstifle_history ();
  60.  
  61. /* Return 1 if the history is stifled, 0 if it is not. */
  62. extern int history_is_stifled ();
  63.  
  64. /* Information about the history list. */
  65.  
  66. /* Return a NULL terminated array of HIST_ENTRY which is the current input
  67.    history.  Element 0 of this list is the beginning of time.  If there
  68.    is no history, return NULL. */
  69. extern HIST_ENTRY **history_list ();
  70.  
  71. /* Returns the number which says what history element we are now
  72.    looking at.  */
  73. extern int where_history ();
  74.   
  75. /* Return the history entry at the current position, as determined by
  76.    history_offset.  If there is no entry there, return a NULL pointer. */
  77. HIST_ENTRY *current_history ();
  78.  
  79. /* Return the history entry which is logically at OFFSET in the history
  80.    array.  OFFSET is relative to history_base. */
  81. extern HIST_ENTRY *history_get ();
  82.  
  83. /* Return the number of bytes that the primary history entries are using.
  84.    This just adds up the lengths of the_history->lines. */
  85. extern int history_total_bytes ();
  86.  
  87. /* Moving around the history list. */
  88.  
  89. /* Set the position in the history list to POS. */
  90. int history_set_pos ();
  91.  
  92. /* Back up history_offset to the previous history entry, and return
  93.    a pointer to that entry.  If there is no previous entry, return
  94.    a NULL pointer. */
  95. extern HIST_ENTRY *previous_history ();
  96.  
  97. /* Move history_offset forward to the next item in the input_history,
  98.    and return the a pointer to that entry.  If there is no next entry,
  99.    return a NULL pointer. */
  100. extern HIST_ENTRY *next_history ();
  101.  
  102. /* Searching the history list. */
  103.  
  104. /* Search the history for STRING, starting at history_offset.
  105.    If DIRECTION < 0, then the search is through previous entries,
  106.    else through subsequent.  If the string is found, then
  107.    current_history () is the history entry, and the value of this function
  108.    is the offset in the line of that history entry that the string was
  109.    found in.  Otherwise, nothing is changed, and a -1 is returned. */
  110. extern int history_search ();
  111.  
  112. /* Search the history for STRING, starting at history_offset.
  113.    The search is anchored: matching lines must begin with string. */
  114. extern int history_search_prefix ();
  115.  
  116. /* Search for STRING in the history list, starting at POS, an
  117.    absolute index into the list.  DIR, if negative, says to search
  118.    backwards from POS, else forwards.
  119.    Returns the absolute index of the history element where STRING
  120.    was found, or -1 otherwise. */
  121. extern int history_search_pos ();
  122.  
  123. /* Managing the history file. */
  124.  
  125. /* Add the contents of FILENAME to the history list, a line at a time.
  126.    If FILENAME is NULL, then read from ~/.history.  Returns 0 if
  127.    successful, or errno if not. */
  128. extern int read_history ();
  129.  
  130. /* Read a range of lines from FILENAME, adding them to the history list.
  131.    Start reading at the FROM'th line and end at the TO'th.  If FROM
  132.    is zero, start at the beginning.  If TO is less than FROM, read
  133.    until the end of the file.  If FILENAME is NULL, then read from
  134.    ~/.history.  Returns 0 if successful, or errno if not. */
  135. extern int read_history_range ();
  136.  
  137. /* Write the current history to FILENAME.  If FILENAME is NULL,
  138.    then write the history list to ~/.history.  Values returned
  139.    are as in read_history ().  */
  140. extern int write_history ();
  141.  
  142. /* Append NELEMENT entries to FILENAME.  The entries appended are from
  143.    the end of the list minus NELEMENTs up to the end of the list. */
  144. int append_history ();
  145.  
  146. /* Truncate the history file, leaving only the last NLINES lines. */
  147. extern int history_truncate_file ();
  148.  
  149. /* History expansion. */
  150.  
  151. /* Expand the string STRING, placing the result into OUTPUT, a pointer
  152.    to a string.  Returns:
  153.  
  154.    0) If no expansions took place (or, if the only change in
  155.       the text was the de-slashifying of the history expansion
  156.       character)
  157.    1) If expansions did take place
  158.   -1) If there was an error in expansion.
  159.    2) If the returned line should just be printed.
  160.  
  161.   If an error ocurred in expansion, then OUTPUT contains a descriptive
  162.   error message. */
  163. extern int history_expand ();
  164.  
  165. /* Extract a string segment consisting of the FIRST through LAST
  166.    arguments present in STRING.  Arguments are broken up as in
  167.    the shell. */
  168. extern char *history_arg_extract ();
  169.  
  170. /* Return the text of the history event beginning at the current
  171.    offset into STRING. */
  172. extern char *get_history_event ();
  173.  
  174. /* Return an array of tokens, much as the shell might.  The tokens are
  175.    parsed out of STRING. */
  176. extern char **history_tokenize ();
  177.  
  178. /* Exported history variables. */
  179. extern int history_base;
  180. extern int history_length;
  181. extern int max_input_history;
  182. extern char history_expansion_char;
  183. extern char history_subst_char;
  184. extern char history_comment_char;
  185. extern char *history_no_expand_chars;
  186.  
  187. #ifdef __cplusplus
  188. }
  189. #endif
  190.